import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-news',
  templateUrl: './news.component.html',
  styleUrls: ['./news.component.scss']
})
export class NewsComponent implements OnInit {



  /*这是属性不是变量   不能使用var 修饰
    前面不加修饰符默认为 public
  */
  public title="我是新闻组件";
  public content='<h2>我是一个Html标签</h2>';

  //定义数组
  public arr=['1','2','3'];
 
  public list:any[]=['这是字符串',123,'这是字符串'];

  public items:Array<any>=['ada',1,'11'];


  //对象数组
  public userlist:any[]=[{
    username:'张三',
    age:20
  },{
    username:'李四',
    age:30
  },{
    username:'王五',
    age:40
  },]



  //嵌套数组
  public students:any[]=[{
    name1:'教师信息列表',
    userList:[{
      Name:'张老师',
      Age:22
    },{
      Name:'李老师',
      Age:22
    },{
      Name:'王老师',
      Age:22
    }]
  },{
    name1:'学生信息表',
    userList:[{
      Name:'杜康',
      Age:22
    },{
      Name:'秦雨田',
      Age:22
    },{
      Name:'陈城',
      Age:22
    },{
      Name:'陈兴豪',
      Age:22
    },{
      Name:'樊烨',
      Age:22
    },{
      Name:'甘陈浩',
      Age:22
    }]

  }]



  constructor() { }

  ngOnInit(): void {


    //改变属性的值
    this.title='我是改过的新闻组件';
  }

}
